﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Dubbo.Rpc
{
    public interface IResult
    {
        /**
	     * Get invoke result.
	     * 
	     * @return result. if no result return null.
	     */
        object getValue();

        /**
         * Get exception.
         * 
         * @return exception. if no exception return null.
         */
        Exception getException();

        /**
         * Has exception.
         * 
         * @return has exception.
         */
        bool hasException();

        /**
         * Recreate.
         * 
         * <code>
         * if (hasException()) {
         *     throw getException();
         * } else {
         *     return getValue();
         * }
         * </code>
         * 
         * @return result.
         * @throws if has exception throw it.
         */
        object recreate();

        /**
         * get attachments.
         *
         * @return attachments.
         */
        Dictionary<string, string> getAttachments();

        /**
         * get attachment by key.
         *
         * @return attachment value.
         */
        string getAttachment(string key);

        /**
         * get attachment by key with default value.
         *
         * @return attachment value.
         */
        string getAttachment(string key, string defaultValue);
    }
}
